<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        div{
            width: 200px;
            height: 200px;
            background: green;
            /* background-color: rgba(red, green, blue, alpha); */
        }
    </style>
</head>
<body>
    <div id="box"></div>
    <script>
        var box = document.getElementById('box');
        var str = '0123456789abcdef';
        box.onclick = function(){
            var color = '#';
            for(i=0;i<6;i++){
                var ky = Math.floor(Math.random()*str.length);
                color += str[ky];
            }
            console.log(color)
            this.style.background = color;
        }
        
        // box.onclick = function(){
        //     var r = Math.floor(Math.random()*256);
        //     var g = Math.floor(Math.random()*256);
        //     var b = Math.floor(Math.random()*256);
        //     var a = Math.random();
        //     rgba = 'rgba('+r+','+g+','+b+','+a+')'
        //     this.style.background = rgba;
        // }
    </script>
</body>
</html>